package com.zy.design.pattern.flyweight;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @author zhaoyi
 * @date 2021/4/21 14:17
 */
@Data
@AllArgsConstructor
public class WarpInt {
    private Integer value;

    /**
     * 覆盖finalize，在回收的时候会执行。
     * @throws Throwable
     */
    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        System.out.println("!!! 已经无强引用指向WarpInt, 回收"+value);
        MyIntegerCache.gcRemove(value);
    }
}
